package org.example.mall.admin.configuration.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author hzq
 * @date 2021/10/12 16:59
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class BaseException extends RuntimeException {

    /**
     * 状态码
     */
    private Integer code;

    /**
     * 消息提示
     */
    private String message;

    /**
     * 异常
     */
    private Object data;

    public BaseException(String message) {
        super(message);
        this.code = Status.ERROR.getCode();
        this.message = message;
    }

    public BaseException(Status status) {
        super(status.getMessage());
        this.code = status.getCode();
        this.message = status.getMessage();
    }

    public BaseException(Status status, Object data) {
        this(status);
        this.data = data;
    }

    public BaseException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BaseException(Integer code, String message, Object data) {
        this(code, message);
        this.data = data;
    }
}
